Notice that in contrast to the [[Lagrangian]], the Hamiltonian for a system is dependent on the [[conjugate momentum]].
A basic definition of the Hamiltonian is given here in terms of [Generalized coordinates](Generalized%20coordinates.md) as

which generalizes to systems of $N$ sub-systems (or classical particles) as
$\mathcal{H}(q,p)=\sum_{i=1}^Np_i\dot{q}_i(p_i,q_i)-\mathcal{L}(q_i,\dot{q}_i(p_i,q_i))$
# Relationship to the Lagrangian
The Hamiltonian is obtained from a given [[Lagrangian]] with the following [[Legendre transformation]]:
$\mathcal{H}(q,p)=p\dot{q}(p,q)-\mathcal{L}(q,\dot{q}(p,q))$ ^6fdda0
## Conserved Hamiltonians
If $\frac{\partial\mathcal{L}}{\partial t} =0,$ that is if the Lagrangian is time independent, the [[Hamiltonians]] is [conserved](Conserved%20quantity.md).
### Noether's theorem
[[Noether's theorem]]
### The total energy of a system
In addition [conserved Hamiltonians](Hamiltonians.md#Conserved%20Hamiltonians) also equate to the total [energy](Mechanics%20(index).md#Energy) in a system if the relation between [Cartesian coordinates](Mechanics%20(index).md#coordinate%20systems) and [Generalized coordinates](Generalized%20coordinates.md) is time independent.
# In terms of Hamiltonian Density
[Hamiltonian density](Hamiltonian%20density.md) refers the the Hamiltonian over a region where a [field](Field.md) is defined and we obtain the Hamiltonian by integrating the Hamiltonian density over all of space.
#Mechanics